<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>编辑书籍</title>
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/5.3.0/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>
<body>
<div class="container">
  <h1 align="center">编辑书籍</h1>
  <form th:action="@{/books/edit/{id}(id=${book.id})}" method="post">
    <div class="mb-3">
      <label for="title" class="form-label">名称</label>
      <input type="text" name="title" id="title" class="form-control" th:value="${book.title}">
    </div>
    <div class="mb-3">
      <label for="author" class="form-label">作者</label>
      <input type="text" name="author" id="author" class="form-control" th:value="${book.author}">
    </div>
    <div class="mb-3">
      <label for="category" class="form-label">分类</label>
      <select name="category.id" id="category" class="form-select">
        <option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.name}"
                th:selected="${category.id == book.category.id}"></option>
      </select>
    </div>
    <div class="mb-3">
      <label for="publishDate" class="form-label">发行日期</label>
      <div class="input-group">
        <input type="month" id="publishDate" name="publishDate" required class="form-control" th:value="${book.publishDate}">
        <span class="input-group-text"><i class="fas fa-calendar"></i></span>
      </div>
    </div>
    <!-- 添加返回按钮 -->
    <a href="javascript:history.back()" class="btn btn-primary">
      <i class="fas fa-arrow-left"></i> 返回
    </a>
    <button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> 保存</button>
  </form>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>